package com.fth.learn.chapter01;

/**
 * 运算符
 * YiMi
 *
 * @author YiMi
 * @version 1.0
 * @date 2023/4/8 15:45
 */

public class LearnOptions {

    public static void main(String[] args) {
        System.out.println(3/2);//1
        System.out.println(3/2.0);//1.5
        //23的个位数

        System.out.printf("个位是%d\n",23 % 10);
        //23的十位数
        System.out.printf("十位是%d\n",23 / 10);
        int aint = 1561561;
        System.out.printf("个位是%d\n",aint % 10);
        System.out.printf("十位是%d\n",aint % 100/10);//aint / 10%10  10的1次方
        System.out.printf("百位是%d\n",aint %1000/100);//aint / 100%10   10的2次方
        System.out.printf("千位是%d\n",aint %10000/1000);//aint / 1000%10   10的3次方
        System.out.printf("万位是%d\n",aint %100000/10000);//aint / 10000%10   10的4次方
        System.out.printf("十万位是%d\n",aint %1000000/100000);//aint / 100000%10   10的5次方
        System.out.printf("百万位是%d\n",aint %10000000/1000000);//aint / 1000000%10   10的6次方
        System.out.printf("千万位是%d\n",aint %100000000/10000000);//aint / 10000000%10   10的7次方






        System.out.println(getPosition(aint,0));
        System.out.println(getPosition(aint,1));

    }

    //你要告诉我求那个数  aint 告诉我求第几位 返回一个整数

    //封装
    static int getPosition(int aint,int index){

        int sum=1;
        for(int i=0;i<index;i++){
            sum=sum*10;
        }
        return aint /sum   %10;

    }

}
